﻿using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using K9Nano.Application;

namespace K9Nano.Domain
{
    public static class RepositoryExtensions
    {
        public static ValueTask<List<TEntity>> GetPagedListAsync<TEntity, TKey>(this IRepository<TEntity, TKey> repository,
            PagedInputDto<TEntity> input,
            CancellationToken cancellation = default) 
            where TEntity : class, IEntity<TKey>
            where TKey : IEquatable<TKey>
        {
            return repository.GetPagedListAsync(input.Predicate(), input.OrderBy(), input.PageIndex, input.PageSize, cancellation);
        }
    }
}